﻿using System;
using System.Windows.Forms;

namespace DropBoxToDo.UserControls
{
    public partial class EmptyTaskControl : UserControl
    {
        private string _initialTaskName = "Type task here...";

        public Func<string, bool> OnNewTaskCreated; 

        public EmptyTaskControl()
        {
            InitializeComponent();
            textBox.Text = _initialTaskName;
        }

        private void textBox_Enter(object sender, EventArgs e)
        {
            if (textBox.Text == _initialTaskName)
                textBox.Text = string.Empty;
        }

        private void textBox_Leave(object sender, EventArgs e)
        {
            textBox.Text = _initialTaskName;
        }

        private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyValue == 13 && OnNewTaskCreated != null)
            {
                OnNewTaskCreated(textBox.Text);
            }
        }

        
    }
}
